<template>
 <div>
       <el-table
      :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      "
      style="width: 100%; text-align: center; margin-top: 10px"
      border
      lazy
    >
      <el-table-column prop="port" label="端口号" width="100">
      </el-table-column>
      <el-table-column prop="ip" label="服务器地址" width="150">
      </el-table-column>
      <el-table-column prop="content" label="描述" width="150">
      </el-table-column>
      <el-table-column prop="type" label="类型" width="150"> </el-table-column>
      <el-table-column prop="createTime" label="创建时间"> </el-table-column>
      <el-table-column prop="state" label="状态"> </el-table-column>
      <el-table-column prop="user" label="处理人"> </el-table-column>
      <el-table-column prop="solveCont" label="处理内容"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="opendeal(scope.row)" :disabled="dis">处理方法</el-button>
          <el-button size="mini" @click="re4(scope.row)" :disabled="dis">完成</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <el-pagination
      @current-change="currentChangeHandle"
      @size-change="sizeChangeHandle"
      layout="prev, pager, next, jumper"
      :total="total"
      style="text-align: right"
    >
    </el-pagination>
     <!-- 处理方法 -->
    <el-dialog
      title="请描述你的处理方法"
      style="text-align: center"
      :visible.sync="dialogFormVisible1"
    >
      
     <el-form :model="form1">
        <el-form-item label="处理方法" :label-width="formLabelWidth">
          <el-input v-model="form1.solveCont" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>

    
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="update">确 定</el-button>
      </div>
    </el-dialog>
 </div>
</template>

<script>
export default {
created() {
     this.$axios.post("/api/bug/my", {"user":sessionStorage.getItem('mytoken')}).then((res) => {
        console.log(res);
        this.tableData = res.data.data;
        this.total = res.data.total;});
        // 确认管理员身份
    if(sessionStorage.getItem('sex')=="管理员"){
      this.dis=false;
      console.log(this.dis);
    }
  },
 
  methods: {
       update() {
      this.$axios.post("/api/bug/re3",  {
                                        "id":this.id,
                                        "solveCont":this.form1.solveCont,
      }).then((res) => {
        console.log(res);
        this.dialogFormVisible1 = false;
        window.location.reload();
      });
    },

    opendeal(row) {
          this.id=row.id;
      this.dialogFormVisible1 = true;
    },
     re4(row) {
       this.$axios.post("/api/bug/re4",  {"id":row.id}).then((res) => {
        console.log(res);
        this.dialogFormVisible1 = false;
        window.location.reload();
      });
    },
    currentChangeHandle(e) {
      console.log("当前页码", e);
      this.currentPage = e;
    },
    sizeChangeHandle(e) {
      console.log("每页显示多少条数据", e);
      this.pageSize = e;
    },
  },
  data() {
    return {
      dialogFormVisible1: false,
      form1: {},
      formLabelWidth1: "120px",
      dis: true,
      total: 0,
      input: "",
      currentPage: 1,
      pageSize: 10,
      tableData: [],
    };
  },
}
</script>

<style>

</style>